import {createRouter, createWebHistory} from "vue-router"
import deviceRoutes from "@/router/device.ts";
import testManagerRoutes from "@/router/test_manager.ts";
import systemSettingsRoutes from "@/router/system_settings.ts";

const routes = [

    {
        path: '/home',
        name: 'home',
        component: () => import("@/views/HomeView.vue"),

        meta: {title: '首页', isShow: true, closable: false, icon: 'HomeFilled'},
        children: [

            {
                path: '/dashboard',
                name: 'dashboard',
                component: () => import("@/views/DashboardView.vue"),
                meta: {title: 'Dashboard', isShow: true, closable: true, icon: 'Odometer'},
            },
            ...deviceRoutes,  // 设备管理
            ...testManagerRoutes,
            ...systemSettingsRoutes,

        ]
    },
    {
        path: '/',
        redirect: '/home',
        meta: {title: '首页', isShow: false, closable: false},
    },
    {
        path: '/layout',
        name: 'layout',
        component: () => import("@/layout/layout-framework.vue"),
        meta: {title: 'layout', isShow: false, closable: true},
    },
    {
        path: '/temp',
        name: '/temp',
        // component: () => import("@/components/NineSquareGrid.vue"),
        meta: {title: 'temp', isShow: false, closable: true},
    },
    {
        path: '/temp/device',
        name: '/temp/device',
        component: () => import("@/views/device/DeviceLayout.vue"),
        meta: {title: 'tempDevice', isShow: false, closable: true},
    }
]

const router = createRouter(
    {
        history: createWebHistory(),
        routes
    }
);

router.afterEach((to) => {
    document.title = to.meta.title as string || ''
})
export default router
export const allRoutes = routes